package fr.iut.tp3.controller.events;

import java.util.ArrayList;
import java.util.List;

public class EventDispatcher {

	private static EventDispatcher instance;
	private List<EventListener> listeners = new ArrayList<EventListener>();

	public static EventDispatcher getInstance() {
		if (instance == null) {
			instance = new EventDispatcher();
		}
		return instance;
	}

	public void registerListener(EventListener listener) {
		listeners.add(listener);
	}

	public void sendEvent(Event e) {
		for (EventListener listener : listeners) {
			listener.onEvent(e);
		}
	}
}
